# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=xnvme
pkgver=0.7.4
pkgrel=1
pkgdesc="cross-platform libraries and tools for NVMe devices"
url="https://xnvme.io"
# 32bit unsupported
arch="all !armhf !armv7 !x86"
license="BSD-3-Clause"
makedepends="bsd-compat-headers libaio-dev liburing-dev linux-headers meson py3-gpep517 py3-setuptools py3-wheel"
subpackages="py3-$pkgname-pyc py3-$pkgname:_python:noarch $pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/OpenMPDK/xNVMe/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/xNVMe-$pkgver"
case "$CARCH" in
aarch64|x86_64) makedepends="$makedepends libvfn-dev" ;;
esac

build() {
	abuild-meson -Dexamples=false -Dwith-spdk=false \
		. output
	meson compile -C output

	cd python/bindings
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output

	cd python/bindings
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
	rm -r "$pkgdir"/usr/lib/python3*/site-packages/xnvme/ctypes_bindings/tests
}

_python() {
	amove usr/lib/python*
}

sha512sums="
b905efb8b0809d1bba3fa7cc6c42362bd5bf10fa8810a8b76944aff312bfdea04e8ac1a949fd84d5f1b74c178157eebf213f23601a989fe779690b558d15f03d  xnvme-0.7.4.tar.gz
"
